<?php

class Agitum_Sms_Gate 
{
	public static function factory($gate, $config) 
	{
		if ($config instanceof Zend_Config) {
            $config = $config->toArray();
        }
        
		$gateNamespace = 'Agitum_Sms_Gate';

        $gateName = $gateNamespace . '_';
        $gateName .= str_replace(' ', '_', ucwords(str_replace('_', ' ', strtolower($gate))));

        $gate = new $gateName($config);

        if (! $gate instanceof Agitum_Sms_Gate_Abstract) {
            throw new Exception("SMS gate class '$gateName' does not extend Agitum_Sms_Gate_Abstract");
        }

        return $gate;
    }
}